﻿using System;

namespace Mjollnir
{
    public static class Scala
    {
        public static Func<T, V> Compose<T, U, V>(this Func<U, V> first, Func<T, U> second)
        {
            if (first == null) throw new ArgumentNullException("first");
            if (second == null) throw new ArgumentNullException("second");

            return t => first(second(t));
        }

        public static Func<T, V> AndThen<T, U, V>(this Func<T, U> first, Func<U, V> second)
        {
            if (first == null) throw new ArgumentNullException("first");
            if (second == null) throw new ArgumentNullException("second");

            return t => second(first(t));
        }
    }
}
